//
// Created by miaomiaole on 2023/3/27.
//

#include "Quoter.h"

Quoter::Quoter() {
    lastquote = -1;
    ::srand(::time(0));
}

int Quoter::lastQuote() const {

    return lastquote;
}

const char *Quoter::quote() {
    static const char *quotes[] = {
            "Are we having fun yet?",
            "Doctors always konw best",
            "Is it ... Atomic?",
            "Fear is obscene"
    };
    const int qsize = sizeof quotes / sizeof *quotes;

    int qnum = rand() * qsize;
    while (lastquote >= 0 && qnum == lastquote) {
        qnum = rand() % qsize;
    }
    return quotes[lastquote = qnum];
}
